from rest_framework.viewsets import ModelViewSet
from apps.goods.models import *
from apps.meiduo_admin.utils import UserDefinePagination
from ..serializers.spu import *


class SPUGoodsViewSet(ModelViewSet):

    def get_queryset(self):
        keyword = self.request.query_params.get("keyword")
        if keyword:
            return SPU.objects.filter(name__contains=keyword)
        return SPU.objects.all()
    serializer_class = SPUGoodsViewSetSerializer
    pagination_class = UserDefinePagination
